<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>价格为:{{funll}}</h2>
    </div>
    <script src="../../node_modules/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                books: [{
                    id: 100,
                    name: 'qing',
                    price: 144
                }, {
                    id: 100,
                    name: 'qing',
                    price: 166
                }, {
                    id: 100,
                    name: 'qing',
                    price: 187
                }, {
                    id: 100,
                    name: 'qing',
                    price: 145
                }, ]
            },
            //计算属性
            computed: {
                funll: function() {
                    let retaa = 0;
                    for (let i = 0; i < this.books.length; i++) {
                        retaa += this.books[i].price
                    }
                    return retaa
                }
            },


        })
    </script>
</body>

</html>